﻿namespace PMS.Client.FrmOrgan
{
    using PMS.BLL;
    using PMS.Client.Controls;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class FrmOrganCheck : Form
    {
        private DataGridViewTextBoxColumn Address;
        private DataGridViewTextBoxColumn BankID;
        private DataGridViewTextBoxColumn BankName;
        private ToolStripButton btnDelete;
        private ToolStripButton btnUpdate;
        private DataGridViewTextBoxColumn BuildName;
        private IContainer components = null;
        private DataGridViewTextBoxColumn Contact;
        private UCDataGridView dataGridView1;
        private DataGridViewTextBoxColumn Functions;
        private DataGridViewTextBoxColumn IOrganName;
        private DataGridViewTextBoxColumn LegalPerson;
        private DataGridViewTextBoxColumn LevelName;
        private OrganChangeLogBLL logbll = new OrganChangeLogBLL();
        private DataGridViewTextBoxColumn LogID;
        private DataGridViewTextBoxColumn LogType;
        private DataGridViewTextBoxColumn OrganBranchCode;
        private DataGridViewTextBoxColumn OrganCode;
        private DataGridViewTextBoxColumn OrganDescription;
        private DataGridViewTextBoxColumn OrganName;
        private DataGridViewTextBoxColumn ParentName;
        private DataGridViewTextBoxColumn PermitNo;
        private DataGridViewTextBoxColumn PermitOrganCount;
        private DataGridViewTextBoxColumn Postcode;
        private DataGridViewTextBoxColumn RealityOrganCount;
        private DataGridViewTextBoxColumn Remark;
        private DataGridViewTextBoxColumn RoleName;
        private DataGridViewTextBoxColumn Tel;
        private ToolStrip toolStrip1;
        private DataGridViewTextBoxColumn TypeName;

        public FrmOrganCheck()
        {
            this.InitializeComponent();
            this.dataGridView1.AutoGenerateColumns = false;
            this.dataGridView1.DataSource = this.logbll.GetViewList();
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.dataGridView1.SelectedRows.Count <= 0)
            {
                MessageBox.Show("请选择要审核的记录!");
            }
            else if (MessageBox.Show("确定删除？", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK)
            {
                int logID = int.Parse(this.dataGridView1.SelectedRows[0].Cells["LogID"].Value.ToString());
                if (this.logbll.Delete(logID))
                {
                    this.dataGridView1.DataSource = this.logbll.GetViewList();
                }
                else
                {
                    MessageBox.Show("删除失败!");
                }
            }
        }

        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (this.dataGridView1.SelectedRows.Count <= 0)
            {
                MessageBox.Show("请选择要审核的记录!");
            }
            else
            {
                int logID = int.Parse(this.dataGridView1.SelectedRows[0].Cells["LogID"].Value.ToString());
                string organName = "";
                if (this.dataGridView1.SelectedRows[0].Cells["LogType"].Value.ToString() == "新增")
                {
                    organName = this.dataGridView1.SelectedRows[0].Cells["OrganName"].Value.ToString();
                }
                else
                {
                    organName = this.dataGridView1.SelectedRows[0].Cells["IOrganName"].Value.ToString();
                }
                FrmCheckDialog dialog = new FrmCheckDialog(logID, organName);
                dialog.ShowDialog();
                if (dialog.DialogResult == DialogResult.OK)
                {
                    this.dataGridView1.DataSource = this.logbll.GetViewList();
                }
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void FrmOrganCheck_FormClosing(object sender, FormClosingEventArgs e)
        {
            base.DialogResult = DialogResult.OK;
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            DataGridViewCellStyle style = new DataGridViewCellStyle();
            DataGridViewCellStyle style2 = new DataGridViewCellStyle();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(FrmOrganCheck));
            this.dataGridView1 = new UCDataGridView(this.components);
            this.LogID = new DataGridViewTextBoxColumn();
            this.IOrganName = new DataGridViewTextBoxColumn();
            this.LogType = new DataGridViewTextBoxColumn();
            this.OrganName = new DataGridViewTextBoxColumn();
            this.ParentName = new DataGridViewTextBoxColumn();
            this.OrganCode = new DataGridViewTextBoxColumn();
            this.LevelName = new DataGridViewTextBoxColumn();
            this.RoleName = new DataGridViewTextBoxColumn();
            this.TypeName = new DataGridViewTextBoxColumn();
            this.BuildName = new DataGridViewTextBoxColumn();
            this.OrganDescription = new DataGridViewTextBoxColumn();
            this.OrganBranchCode = new DataGridViewTextBoxColumn();
            this.PermitNo = new DataGridViewTextBoxColumn();
            this.Functions = new DataGridViewTextBoxColumn();
            this.BankName = new DataGridViewTextBoxColumn();
            this.BankID = new DataGridViewTextBoxColumn();
            this.LegalPerson = new DataGridViewTextBoxColumn();
            this.PermitOrganCount = new DataGridViewTextBoxColumn();
            this.RealityOrganCount = new DataGridViewTextBoxColumn();
            this.Address = new DataGridViewTextBoxColumn();
            this.Postcode = new DataGridViewTextBoxColumn();
            this.Contact = new DataGridViewTextBoxColumn();
            this.Tel = new DataGridViewTextBoxColumn();
            this.Remark = new DataGridViewTextBoxColumn();
            this.toolStrip1 = new ToolStrip();
            this.btnUpdate = new ToolStripButton();
            this.btnDelete = new ToolStripButton();
            ((ISupportInitialize) this.dataGridView1).BeginInit();
            this.toolStrip1.SuspendLayout();
            base.SuspendLayout();
            this.dataGridView1.AllowUserToAddRows = false;
            this.dataGridView1.AllowUserToDeleteRows = false;
            this.dataGridView1.AllowUserToResizeRows = false;
            this.dataGridView1.BackgroundColor = Color.FromArgb(0xa4, 0xc4, 0xeb);
            this.dataGridView1.BorderStyle = BorderStyle.None;
            this.dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
            this.dataGridView1.Columns.AddRange(new DataGridViewColumn[] { 
                this.LogID, this.IOrganName, this.LogType, this.OrganName, this.ParentName, this.OrganCode, this.LevelName, this.RoleName, this.TypeName, this.BuildName, this.OrganDescription, this.OrganBranchCode, this.PermitNo, this.Functions, this.BankName, this.BankID, 
                this.LegalPerson, this.PermitOrganCount, this.RealityOrganCount, this.Address, this.Postcode, this.Contact, this.Tel, this.Remark
             });
            style.Alignment = DataGridViewContentAlignment.MiddleLeft;
            style.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            style.Font = new Font("宋体", 9f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            style.ForeColor = SystemColors.ControlText;
            style.SelectionBackColor = SystemColors.Highlight;
            style.SelectionForeColor = SystemColors.ControlText;
            style.WrapMode = DataGridViewTriState.False;
            this.dataGridView1.DefaultCellStyle = style;
            this.dataGridView1.Dock = DockStyle.Fill;
            this.dataGridView1.EnableHeadersVisualStyles = false;
            this.dataGridView1.GridColor = Color.FromArgb(0xd0, 0xd7, 0xe5);
            this.dataGridView1.HighlightSelectedColumnHeaders = false;
            this.dataGridView1.Location = new Point(0, 0x36);
            this.dataGridView1.MultiSelect = false;
            this.dataGridView1.Name = "dataGridView1";
            this.dataGridView1.ReadOnly = true;
            this.dataGridView1.RowTemplate.Height = 0x17;
            this.dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            this.dataGridView1.Size = new Size(0x3f0, 0x1fc);
            this.dataGridView1.TabIndex = 13;
            this.LogID.DataPropertyName = "LogID";
            style2.Alignment = DataGridViewContentAlignment.MiddleCenter;
            style2.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.LogID.DefaultCellStyle = style2;
            this.LogID.HeaderText = "ID";
            this.LogID.Name = "LogID";
            this.LogID.ReadOnly = true;
            this.LogID.Width = 30;
            this.IOrganName.DataPropertyName = "IOrganName";
            this.IOrganName.HeaderText = "机构名称";
            this.IOrganName.Name = "IOrganName";
            this.IOrganName.ReadOnly = true;
            this.IOrganName.Width = 150;
            this.LogType.DataPropertyName = "LogType";
            this.LogType.HeaderText = "日志类型";
            this.LogType.Name = "LogType";
            this.LogType.ReadOnly = true;
            this.OrganName.DataPropertyName = "OrganName";
            this.OrganName.HeaderText = "修改机构名";
            this.OrganName.Name = "OrganName";
            this.OrganName.ReadOnly = true;
            this.OrganName.Width = 150;
            this.ParentName.DataPropertyName = "ParentName";
            this.ParentName.HeaderText = "隶属机构";
            this.ParentName.Name = "ParentName";
            this.ParentName.ReadOnly = true;
            this.ParentName.Width = 150;
            this.OrganCode.DataPropertyName = "OrganCode";
            this.OrganCode.HeaderText = "机构编码";
            this.OrganCode.Name = "OrganCode";
            this.OrganCode.ReadOnly = true;
            this.OrganCode.Width = 150;
            this.LevelName.DataPropertyName = "LevelName";
            this.LevelName.HeaderText = "机构级别";
            this.LevelName.Name = "LevelName";
            this.LevelName.ReadOnly = true;
            this.LevelName.Width = 120;
            this.RoleName.DataPropertyName = "RoleName";
            this.RoleName.HeaderText = "机构性质";
            this.RoleName.Name = "RoleName";
            this.RoleName.ReadOnly = true;
            this.TypeName.DataPropertyName = "TypeName";
            this.TypeName.HeaderText = "机构类别";
            this.TypeName.Name = "TypeName";
            this.TypeName.ReadOnly = true;
            this.BuildName.DataPropertyName = "BuildName";
            this.BuildName.HeaderText = "机构编码";
            this.BuildName.Name = "BuildName";
            this.BuildName.ReadOnly = true;
            this.OrganDescription.DataPropertyName = "OrganDescription";
            this.OrganDescription.HeaderText = "机构备注";
            this.OrganDescription.Name = "OrganDescription";
            this.OrganDescription.ReadOnly = true;
            this.OrganBranchCode.DataPropertyName = "OrganBranchCode";
            this.OrganBranchCode.HeaderText = "机构组织代码";
            this.OrganBranchCode.Name = "OrganBranchCode";
            this.OrganBranchCode.ReadOnly = true;
            this.OrganBranchCode.Width = 150;
            this.PermitNo.DataPropertyName = "PermitNo";
            this.PermitNo.HeaderText = "批准文号";
            this.PermitNo.Name = "PermitNo";
            this.PermitNo.ReadOnly = true;
            this.Functions.DataPropertyName = "Functions";
            this.Functions.HeaderText = "职能";
            this.Functions.Name = "Functions";
            this.Functions.ReadOnly = true;
            this.BankName.DataPropertyName = "BankName";
            this.BankName.HeaderText = "开户行";
            this.BankName.Name = "BankName";
            this.BankName.ReadOnly = true;
            this.BankName.Width = 120;
            this.BankID.DataPropertyName = "BankID";
            this.BankID.HeaderText = "银行帐号";
            this.BankID.Name = "BankID";
            this.BankID.ReadOnly = true;
            this.BankID.Width = 120;
            this.LegalPerson.DataPropertyName = "LegalPerson";
            this.LegalPerson.HeaderText = "法人代表";
            this.LegalPerson.Name = "LegalPerson";
            this.LegalPerson.ReadOnly = true;
            this.PermitOrganCount.DataPropertyName = "PermitOrganCount";
            this.PermitOrganCount.FillWeight = 150f;
            this.PermitOrganCount.HeaderText = "允许机构数";
            this.PermitOrganCount.Name = "PermitOrganCount";
            this.PermitOrganCount.ReadOnly = true;
            this.PermitOrganCount.Width = 130;
            this.RealityOrganCount.DataPropertyName = "RealityOrganCount";
            this.RealityOrganCount.HeaderText = "实有机构数";
            this.RealityOrganCount.Name = "RealityOrganCount";
            this.RealityOrganCount.ReadOnly = true;
            this.RealityOrganCount.Width = 130;
            this.Address.DataPropertyName = "Address";
            this.Address.HeaderText = "通信地址";
            this.Address.Name = "Address";
            this.Address.ReadOnly = true;
            this.Postcode.DataPropertyName = "Postcode";
            this.Postcode.HeaderText = "邮编";
            this.Postcode.Name = "Postcode";
            this.Postcode.ReadOnly = true;
            this.Contact.DataPropertyName = "Contact";
            this.Contact.HeaderText = "联系人";
            this.Contact.Name = "Contact";
            this.Contact.ReadOnly = true;
            this.Tel.DataPropertyName = "Tel";
            this.Tel.HeaderText = "电话";
            this.Tel.Name = "Tel";
            this.Tel.ReadOnly = true;
            this.Remark.DataPropertyName = "Remark";
            this.Remark.HeaderText = "备注";
            this.Remark.Name = "Remark";
            this.Remark.ReadOnly = true;
            this.toolStrip1.Items.AddRange(new ToolStripItem[] { this.btnUpdate, this.btnDelete });
            this.toolStrip1.Location = new Point(0, 0);
            this.toolStrip1.Name = "toolStrip1";
            this.toolStrip1.RenderMode = ToolStripRenderMode.System;
            this.toolStrip1.Size = new Size(0x3f0, 0x36);
            this.toolStrip1.TabIndex = 14;
            this.toolStrip1.Text = "toolStrip1";
            this.btnUpdate.AutoSize = false;
            this.btnUpdate.Image = (Image) manager.GetObject("btnUpdate.Image");
            this.btnUpdate.ImageScaling = ToolStripItemImageScaling.None;
            this.btnUpdate.ImageTransparentColor = Color.Magenta;
            this.btnUpdate.Name = "btnUpdate";
            this.btnUpdate.Size = new Size(0x2e, 0x33);
            this.btnUpdate.Text = "审批";
            this.btnUpdate.TextImageRelation = TextImageRelation.ImageAboveText;
            this.btnUpdate.Click += new EventHandler(this.btnUpdate_Click);
            this.btnDelete.AutoSize = false;
            this.btnDelete.Image = (Image) manager.GetObject("btnDelete.Image");
            this.btnDelete.ImageScaling = ToolStripItemImageScaling.None;
            this.btnDelete.ImageTransparentColor = Color.Magenta;
            this.btnDelete.Name = "btnDelete";
            this.btnDelete.Size = new Size(0x2e, 0x33);
            this.btnDelete.Text = "删除";
            this.btnDelete.TextImageRelation = TextImageRelation.ImageAboveText;
            this.btnDelete.Click += new EventHandler(this.btnDelete_Click);
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x3f0, 0x232);
            base.Controls.Add(this.dataGridView1);
            base.Controls.Add(this.toolStrip1);
            base.Icon = (Icon) manager.GetObject("$this.Icon");
            base.Name = "FrmOrganCheck";
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "未审批机构信息列表";
            base.FormClosing += new FormClosingEventHandler(this.FrmOrganCheck_FormClosing);
            ((ISupportInitialize) this.dataGridView1).EndInit();
            this.toolStrip1.ResumeLayout(false);
            this.toolStrip1.PerformLayout();
            base.ResumeLayout(false);
            base.PerformLayout();
        }
    }
}

